# 打印信息
message(STATUS "[second dir] This is BINARY dir " ${PROJECT_BINARY_DIR})
message(STATUS "[second dir] This is SOURCE dir " ${PROJECT_SOURCE_DIR})
message(STATUS "[second dir] cmake_source_dir:" ${PROJECT_SOURCE_DIR})
message(STATUS "[second dir] cmake_current_source_dir:" ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "[second dir] cmake_current_binary_dir:" ${CMAKE_CURRENT_BINARY_DIR})


# 定义工程根目录; CMAKE_SOURCE_DIR为内建变量，表示工程根目录的CMakeLists.txt文件路径
SET(ROOT_DIR ${CMAKE_SOURCE_DIR})

# 是否使用自己的 Math库
option (USE_MYMATH "Use provided math implementation" ${CUSTOM_BUILD_ARG})
# 用于测试替换用的变量
set(TEST_ON 1)
set(TEST_OF 0)
set(VAR "VAR_NEW")

# 加入一个配置头文件，用于处理 CMake 对源码的设置
configure_file (
        "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
        "${CMAKE_CURRENT_BINARY_DIR}/config.h"
)

# 下面两个用法的结果是相同的,set会修改SRC_LIST的值，aux_source_directory 会增加
set(SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
#aux_source_directory(. SRC_LIST)

# 是否编译Math函数
if (USE_MYMATH)
    # 定义头文件搜索路径
    include_directories(${ROOT_DIR}/Math)
    # 需要编译的源码搜索路径
    aux_source_directory(${ROOT_DIR}/Math SRC_LIST)
    message("tt2: ${SRC_LIST}")
endif (USE_MYMATH)

# 指定可执行文件存放目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# 这样可以找到config.h头文件
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

# 构建可执行程序
ADD_EXECUTABLE(sample8 ${SRC_LIST})